/**
 * File: AddonListParser.java
 * Created: Feb 15, 2007 11:30:30 AM
 */
package com;

import java.util.ArrayList;

/**
 * @author Wes Billman
 *
 */
public class AddonListParser {

	public enum ParseResults
	{
		SUCCESS,
		ERROR
	}
	
	public static ArrayList<WowAceAddon> ParseAddonList(String list)
	{
	    	list = list.replace("null", "");
		System.out.println("Parsing... " + list.replace("null", ""));
		
		ArrayList<WowAceAddon> addonList = new ArrayList<WowAceAddon>();
		String[] lines = list.split("\n");
		
		addonList.clear();
		
		for(int i = 0; i < lines.length; i++)
		{
			String[] words = lines[i].split("\t");
			String name = words[0];
			String author = words[1].substring(words[1].lastIndexOf("("), 
						words[1].lastIndexOf(")"));
			String desc = words[1].replace(author, "");
			author = author.replace("(", "");
			author = author.replace(")", "");
			WowAceAddon addon = new WowAceAddon(name, desc, author, "");
			addonList.add(addon);
		}
		
		System.out.println("Parse Complete");
		
		return addonList;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
